﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TGB.Core.Infrastructure;
using TGBTech.Core.Models.DanhMuc;

namespace TGBTech.Core.Models.BaoCao.SoChiTietVLSPHHModel
{
    public class SoChiTietVLSPHHFactory
    {
        //create SoChiTietVLSPHH
        public static SoChiTietVLSPHH createSoChiTietVLSPHH(String hanghoaid)
        {
            //init result
            var result = new SoChiTietVLSPHH();
            //init db 
            using (TGBTechDb db = new TGBTechDb())
            {
                //search hanghoaquery
                var searchHHQuery = from e in db.HangHoa
                                    where e.MaHangHoa == hanghoaid
                                    select e;
                //get hanghoa from query
                var hanghoa = searchHHQuery.First();
                //check hanghoa
                if (hanghoa == null)
                {
                    return result;
                }
                //init resultdata
                result.HangHoaId = hanghoaid;
                result.HangHoaTen = hanghoa.Name;
            }
            //return result
            return result;
        }

        //create SoChiTietVLSPHHModel
        public static SoChiTietVLSPHHModel createSoChiTietVLSPHHModel()
        {
            return null; 
        }
    }
}
